//-----------------------------------------------------------------------
//<copyright file="ChiTietPhieuNhapBLL.cs
//Code gen by tool.
//</copyright>
//-----------------------------------------------------------------------
using System;
using PMS.Exceptions;
using System.Collections.Generic;
using PMS.DAL;
using PMS.Entity;

namespace PMS.BLL
{
	public class ChiTietPhieuNhapBO : BaseBO
	{
		// Interface Instant Object
		private readonly IChiTietPhieuNhapDAO chitietphieunhapInterfaceObject = null;

		// Constructor
		public ChiTietPhieuNhapBO()
		{
			chitietphieunhapInterfaceObject = new DAL.ServiceFactory<IChiTietPhieuNhapDAO>().CurrentDAL;
		}

		#region ChiTietPhieuNhap

		/// <summary>
		///
		/// </summary>
		/// <param name="chitietphieunhap"></param>
		public ChiTietPhieuNhap CreateChiTietPhieuNhap(ChiTietPhieuNhap chitietphieunhap)
		{
			try
			{
				return chitietphieunhapInterfaceObject.CreateChiTietPhieuNhap(chitietphieunhap);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access CreateChiTietPhieuNhap Exception", ex);
			}
		}

		/// <summary>
		///
		/// </summary>
		/// <param name="chitietphieunhap"></param>
		public void UpdateChiTietPhieuNhap(ChiTietPhieuNhap chitietphieunhap)
		{
			try
			{
				chitietphieunhapInterfaceObject.UpdateChiTietPhieuNhap(chitietphieunhap);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access UpdateChiTietPhieuNhapException", ex);
			}
		}

        /// <summary>
        ///
        /// </summary>
        /// <param name="chitietphieunhap"></param>
        public void UpdateChiTietPhieuNhapTonKho(string maCTPN,int qty)
        {
            try
            {
                chitietphieunhapInterfaceObject.UpdateChiTietPhieuNhapTonkho(maCTPN,qty);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access UpdateChiTietPhieuNhapException", ex);
            }
        }

        /// <summary>
        ///
        /// </summary>
        /// <param name="chitietphieunhap"></param>
        public void UpdateChiTietPhieuNhapTonKho(string mathuoc, string solo , int qty)
        {
            try
            {
                ChiTietPhieuNhap nhap = chitietphieunhapInterfaceObject.GetChiTietPhieuNhapByMaThuocAndSoLo(mathuoc, solo);
                if (nhap != null)
                {
                    chitietphieunhapInterfaceObject.UpdateChiTietPhieuNhapTonkho(nhap.MaCTPN, qty);
                }
                else
                {
                    throw new Exception("Chi tiet phieu nhap dose not existed");
                }
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access UpdateChiTietPhieuNhapException", ex);
            }
        }

		/// <summary>
		///
		/// </summary>
		/// <param name="chitietphieunhap"></param>
		public void DeleteChiTietPhieuNhap(ChiTietPhieuNhap chitietphieunhap)
		{
			try
			{
				chitietphieunhapInterfaceObject.DeleteChiTietPhieuNhap(chitietphieunhap);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access DeleteChiTietPhieuNhapException", ex);
			}
		}

        /// <summary>
        ///
        /// </summary>
        /// <param name="SoPN"></param>
        public void DeleteChiTietPhieuNhapBySoPN(string SoPN)
        {
            try
            {
                chitietphieunhapInterfaceObject.DeleteChiTietPhieuNhapBySoPN(SoPN);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access DeletePhieuNhapException", ex);
            }
        }

		/// <summary>
		///
		/// </summary>
		public ChiTietPhieuNhaps GetAllChiTietPhieuNhap()
		{
			try
			{
				return chitietphieunhapInterfaceObject.GetAllChiTietPhieuNhap();
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access GetAllChiTietPhieuNhap Exception", ex);
			}
		}

        /// <summary>
        ///
        /// </summary>
        public ChiTietPhieuNhaps GetAllThuocHetHangTrongThoiGian(int songay)
        {
            try
            {
                return chitietphieunhapInterfaceObject.GetAllThuocHetHangTrongThoiGian(songay);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetAllChiTietPhieuNhap Exception", ex);
            }
        }


        /// <summary>
        ///
        /// </summary>
        public ChiTietPhieuNhaps GetAllChiTietPhieuNhapBySoPN(string SoPN)
        {
            try
            {
                return chitietphieunhapInterfaceObject.GetAllChiTietPhieuNhapBySoPN(SoPN);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetAllChiTietPhieuNhap by PN Exception", ex);
            }
        }

        public ChiTietPhieuNhaps GetAllChiTietPhieuNhapByNgayNhapAndSoPNAndMaThuoc(string SoPN, DateTime? tungay, DateTime? dengnay, string mathuoc)
        {
            try
            {
                return chitietphieunhapInterfaceObject.GetAllChiTietPhieuNhapByNgayNhapAndSoPNAndMaThuoc(SoPN, tungay,dengnay,mathuoc);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetAllChiTietPhieuNhapByNgayNhapAndSoPNAndMaThuoc by PN Exception", ex);
            }
        }

        /// <summary>
        ///
        /// </summary>
        public ChiTietPhieuNhaps GetAllChiTietPhieuNhapByMaThuoc(string mathuoc,string makho, int? lonhon)
        {
            try
            {
                return chitietphieunhapInterfaceObject.GetAllChiTietPhieuNhapByMaThuoc(mathuoc, makho, lonhon);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetAllChiTietPhieuNhap by MaThuoc Exception", ex);
            }
        }

		/// <summary>
		///
		/// </summary>
		/// <param name="maCTPN"></param>
		public ChiTietPhieuNhap GetChiTietPhieuNhapByID(string maCTPN)
		{
			try
			{
				return chitietphieunhapInterfaceObject.GetChiTietPhieuNhapByID(maCTPN);
			}
			catch (Exception ex)
			{
				throw BusinessException.GetException("Business Access GetChiTietPhieuNhapBy ID Exception", ex);
			}
		}


        /// <summary>
        ///
        /// </summary>
        /// <param name="maCTPN"></param>
        public ChiTietPhieuNhap GetChiTietPhieuNhapByMaThuocAndSoLo(string mathuoc, string solo)
        {
            try
            {
                return chitietphieunhapInterfaceObject.GetChiTietPhieuNhapByMaThuocAndSoLo(mathuoc,solo);
            }
            catch (Exception ex)
            {
                throw BusinessException.GetException("Business Access GetChiTietPhieuNhapBy ID Exception", ex);
            }
        }
		#endregion
	}
}
